package com.ceuer.demo.lambda;

public class LambdaTest1 {
	//part3 静态内部类
	static class Like2Impl implements Like{
		@Override
		public void lambda() {
			System.out.println("I Like Lambda2");
		}
	}
	
	public static void main(String[] args) {
		Like like=new Like1Impl();
		like.lambda();
		
		like=new Like2Impl();
		like.lambda();
		
		//part4 局部内部类
		class Like3Impl implements Like{
			@Override
			public void lambda() {
				System.out.println("I Like Lambda3");
			}
		}
		like =new Like3Impl();
		like.lambda();
		
		//part5 匿名内部类:没有类的名称，必须借助接口或者父类
		like=new Like() {
			@Override
			public void lambda() {
				System.out.println("I Like Lambda4");
			}
		};
		
		like.lambda();
		
		//part6 用lambda表达式简化
		like=()->{System.out.println("I Like Lambda5");};
		like.lambda();
		
	}
}

//part1 定义函数式接口
interface Like{
	void lambda();
}

//part2 实现类
class Like1Impl implements Like{
	@Override
	public void lambda() {
		System.out.println("I Like Lambda1");
	}
}